When I started writing Hsoi's App Shell, it was meant to be a learning tool -- something people would be able to go to to learn, from a programmers perspective, just how to do things on and with the MacOS. Eventually it might turn into something (I hope) like a good "tutorial" book, like a Dave Mark book or a Scott Knaster or a Jim Trudeau or Dan Parks Sydow. It's not necessarily meant for beginners, but meant for people that don't know how to do something and want to learn how; you might be an experienced MacOS programmer but perhaps never used offscreen GWorlds before, so you're at least a beginner in that area.
And heck, if it could turn into a "Dave Mark" kinda tutorial thing, what a bonus this medium has! I can show off the latest technologies, I can quickly respond to user feedback, I can make updates within days/weeks. All unlike a book medium which can take years for the next version to come out. And, Hsoi's App Shell is free -- that's a big bonus over $40 books.
But even if in a sense I'm trying to compete with those guys, that doesn't mean you, as a person learning Mac programming, should not read those books. You should. I highly recommend them.
So, what I want to do here is give you an idea and some pointers on how to learn MacOS programming. This is just my opinion on how to learn. I'm sure if you ask a hundred people, you'll get a hundred different answers. So, take this as just my $0.02 on it all.
==================
If you want to program MacOS based computers (man, it's so strange typing "MacOS based computers" instead of saying "program Macintoshes"...these clones and the licensing of the MacOS had to broaden our scope), there are a few basic things that you need:
a MacOS based computer
a compiler
money
Yes, it's not cheap to program Macs. Why is this? Well, if you need to buy a computer, the compiler environment, tutorial books, reference books, etc...it can really add up.
Fortunately, it's getting easier all the time to learn stuff cause more and more things are going "on-line" and becoming available for free.
Lemme tell you how I started and maybe that can give you some guidelines and helps.
==================
Back in undergraduate school I got hooked on these things call MUDs: Multi-User Dungeons (ever play Dungeons & Dragons? it's sorta like that, but interactive and world-wide...pretty cool). I wanted to stop being a player and start running my own mud or at least contribute work to an existing mud. In order to do this, I had to learn how to program. The language most muds are written in is C, so I obviously chose to learn C.
I found a great book called Learn C on the Macintosh by Dave Mark. It's a book that teaches you the basics of the C language (ANSI C) using your Mac. It didn't cover how to program Macs, but I didn't care cause I just wanted to know the language (and I'd be doing most of my MUD work on Unix boxes anyways).
The book was very good (and there is apparently a new version of the book out that's MUCH improved over the version I used). It wasn't a total coverage of C though (but this might have changed in the new version). So, I found another book Learn C in 21 Days which was pretty good. It covered a lot of what Dave alread did (redundancy fosters learning) and covered a LOT of things that Dave didn't cover, a lot of the "power user" things that C can do (like modular programming, preprocessor directives, qsorts and b-tree searching, etc.). The book had a DOS tilt to it (even though it was an ANSI C book), but if you just ignore the DOS stuff, you'll be ok.
I also picked up a copy of The C Programming Language 2nd ed. by Kerrigan and Richie (hope I spelled them right. Can't find the book right now). This book is the authoritative reference book for the ANSI C language. You ought to pick up a copy. It's very user unfriendly, but it's the reference book to have.
Now, in doing all this programming work, I needed an environment to work in. I had a Mac IIvx (at that time, it had 8 megs of RAM and 1 80 meg internal hard drive). When I did Dave Mark's book, I just used the little "sample" compiler that came with the book (THIN C). But then I went to my school's bookstore and bought a copy of Symantec's C++ (then version 6.0). It had the C++ and THINK C compilers in it, and I used them for all my work.
How did I learn? Well, after going through all those books, I felt I had the basics of C down. I began to toy around with MUD code (which was then way over my head). I think I really learned a lot by spending countless hours just going over the code, going over it again, and again, and again, and again. Each time, in my head I'd try to figure out just what was going on in the code.
Plus, I spent a lot of time writing stupid little things. It'd all be ANSI C and quite crude, but I'd have an idea for something (no matter how dumb it was) and try to program it. Like I wrote a little program that could take a weapon damage roll (like 4d6+2. roll 4 six-sided dice, add up the results, then add 2 to the whole thing) and figure out what the average damage that weapon would produce. This way I could try to find out which of 2 weapons was better. So, it was dumb stuff in all honesty, but it was very helpful in giving me experience at programming.
There is no better teacher than experience.
Well, my quest to run the world's greatest MUD had to get put on hold. I wanted to start learning how to program the Macintosh. Just in my daily workings on my computer I'd start to think of all the things that I wish there were, like a way to have more than one thing in the Clipboard (i.e. multiple clipboards), or whatever. So, I thought that since I know how to program, I ought to learn how to program the Mac.
So, again I went to the bookstore and bought some books. Dave Mark's Macintosh C Programming Primer vol. 1 was great. Taught me a lot about the basics of Macintosh programming without getting into the advanced stuff. Scott Knaster's Macintosh Programming Secrets also taught me a lot of the basics. I still refer to these books every once in a while, if not for the code, for Knaster's quirky sense of humor. :)
They taught me the basics of what to do. So again, I just started doing. Sure, my computer crashed all over the place, hundreds of times. But, you live and you learn.
I also was getting tight on space. To just drop this note here, I now own 4 hard drives, all purchased due to my ever-growing programming needs. I bought a 127 meg external drive that i soon outgrew. Then a 540 meg drive. And now I have a 1 gig external that houses all my programming needs. Hopefully I won't need another drive for a while.
And as long as I'm digressing to talking about hardware changes, I started with my 8 megs of RAM. When RamDoubler came out, I snagged it as an inexpensive solution to my problems. It worked and was nice to have 16 megs of RAM to do work. However, using RamDoubler is not really an optimal solution for programming. It can be a source of problems, especially when you're trying to debug things. I suggest that, if you have the money, the first thing to get your computer is a RAM upgrade (of course, if you're rolling in RAM already, don't worry about this step). I have since upgraded my IIvx to 20 megs of REAL RAM, and I can't believe the difference in performance and stability of my Mac (not to say RamDoulber makes for unstable computers, but honestly, it's a cheap solution, tho a pretty cool one. My hats off to the people that conceived and realized it). Also, my old IIvx's 68030 processor (even at 32mHz w/ FPU) just can't cut it anymore. It's not that slow, but it is noticeable. And I'm starting to move into C++ programming, and it's just too darn slow for the compiles.
So, I've now also upgraded my IIvx to a Daystar Turbo 040 processor (running at 40 mHz with an FPU and 128k onboard cache). Lord, she flys now!! I'm quite happy.
But considering the prices of things, why didn't I just upgrade to a PowerPC based Mac or even a clone? I do want to. But right now I have too much invested in non-PPC-native software, and that'd be a HUGE investment to make (to upgrade all my software). I'm still in graduate school right now and too poor to consider that option.
But I'll say this to you: you can really program and develop MacOS software on anything from the original Mac-in-a-box to a 9500/132. Some of the compiler environments need certain hardware and system software specs, so depending what you use, you might need a certain Mac.
If you have some money tho, I'd suggest you try to invest in a PowerPC based Mac or clone. Not only will you enjoy the benifits of the speed, but you will also be able to have an environment in which you can program for, test, run, etc. both PPC and 68k programs. That's one problem that I have: it's hard for me to test my software on PowerMacs. I have to pretty much know what I'm doing and pray that it'll work (and some of HAS's worst bugs are only on PowerMacs).
But I digress....
I just worked a lot on things. I started doing some big projects (that have since been left uncomplete and I know I'll never finish). They are pretty crude and I'll probably never show the source code to anyone, but they helped me learn a lot. I got experience.
Then, I moved to Texas to do my graduate work. I heard about this new product called Metrowerks CodeWarrior and that it was the best thing in the world (at the time, CodeWarrior's claim-to-fame was the first commercial programming environment that could make native PowerPC apps). I didn't want to check it out, but the bookstore had a copy for $99 (let's hear it for educational discounts! If you are affiliated with an educational institution, always first check if you can buy that product at an educational discount. You'll be amazed at the savings). I picked up CodeWarrior 4 Gold, and thought it was ok, but that THINK C still had the edge. Then I got CodeWarrior 5 and was sold. They converted a die-hard Symantec user to a CodeWarrior! And if you are in the market to buy a compiler environment, I will only recommend CodeWarrior (at least for the stuff CodeWarrior can do. If you pick some odd language, well, then I'll suggest something else).
And I've been working ever since.
Hsoi's App Shell has been my project that I've mostly been working on while I've been in grad school. It's been over a year in the making (almost a year and a half), and I learn a lot by doing it. I suggest to you to just dive and go. That'll be your best teacher.
And now...other things.
======
One big question people always ask is: "What language should I use?"
That's a hard question to answer cause there are so many languages out there. Plus, the choice of language is sorta like a "religion war" (things you never talk about at parties: religion, politics, sex, Mac vs. PC, and what language you use).
I would recommend learning C as a starting language. Most schools tend to teach Pascal as the first language, and I think that's fine too. C and Pascal are very very similar in syntax. I never learned Pascal (and still can't really program in it to save my life), but I can pretty fluently read Pascal and translate it into C.
For purposes of MacOS programming, at least having a working knowledge of Pascal is a good thing to have tho. The MacOS was based upon Pascal. That's part of the reason you see the "pascal" keyword in the function definitions of a lot of C and C++ programs (it's due to the calling conventions and the way the argument list is pushed onto the stack, but we won't worry about that right now). Plus, a lot of the Macintosh documentation and source codes are written in Pascal. So, it's at least a good thing to be able to read Pascal. If you know C already, learning to at least read Pascal is made easier.
I also recommend C cause it's sorta a "staple" language that all programmers should know. It's not that hard to learn, it's pretty robust, and just about any platform can use it (i.e. they have C compilers, etc). It's a staple Unix language if nothing else. If you have C in your arsenal, you can't go wrong.
And C is a good stepping stone to C++ (being as how C++ is an "improvement" of the C language). I recommend that after you have C well under your belt (i.e you know it like the back of your hand, you've written a few good serious programs in C) that you move onto C++.
Why not just start with C++? Well, you can, there's nothing wrong with it. But, just cause you know C++ doesn't mean you know C and can program in C (tho it's not too hard to learn, tho you also might hate having to move backwards and find yourself frustrated by it).
Plus, I think that you should really learn MacOS programming from scratch. One of the joys of C++ is that it's an object orriented language. One of the big bonuses of it is that there are many good class libraries out there in the world, like TCL (THINK Class Library) and the great PP (PowerPlant). These are way cool cause they are libraries of reuseable code that can make your life as a developer much easier. The libraries take care of all the things generic to any MacOS program; all you have to do is plug in your specific code. Saves you LOTS of time and effort.
But here's where my problem is. If you start out as a MacOS programmer learning a class library (or other application framework) like PowerPlant, then what you will know how to do is program using PowerPlant -- you won't really learn how the MacOS works. You would be totally helpless and naked if you had to write a program without it.
That's my real beef. I don't care what language you start with, just learn how to really program the MacOS. If you want to start with C++, great. Just start by learning the C++ language, then learn how to make MacOS programs and applications by yourself. Later after you really know what's going on, then you can move to the luxury of a library like PowerPlant (and you should!).
Do you follow me?
So, that's why I think C should be where you start.
Then, learn the language first. Don't worry about learning the MacOS interfaces and stuff, just get the language down (do ANSI C stuff). Then move to the MacOS stuff.
==========
What else?
Well, just some "pointers":
have a lot of desire, dedication, hard work, be a sucker for self-inflicted punishment, enjoy late nights, be thankful if you have a very forgiving significant other, enjoy caffiene, nicotine (for us cigarette smokers), sleep (ha!), patience.
It's not easy, but it's very fun and greatly rewarding to do.
Biggest thing to remember: be patient. It takes a long time to get really good at programming. You just have to stick with it for a long time. And don't think you can just work on it 24-7 for a while and that'll make you good. It won't. It'll just make you tired, braindead, and all your friends will think you've died since you never leave the house anymore (and they might be right....you'll be so pale from lack of sunlight....).
You can't rush it. Program for a while, take some time off. Part of the reason it took me so long to get Hsoi's App Shell out is that (aside from being busy in grad school), I'd take a couple months off totally from programming. I'd totally avoid it. That really helped cause it helps you get through burnout, mental blocks, etc.. And things like burnout are caused when you don't balance things well enough in your life. Balance is good.
Oh, another handy thing to help you learn: if you can obtain the code of a program that you use (like the code for NewsWatcher, or even just use the HAS code and demo app), then get the code, compile it, and then run the program with a high-level debugger like the MW Debugger. This will allow you to step through the code from start to finish and totally watch exactly what is going on. You'll learn a lot watching the code actually work. If you want to make this more of a challenge, isolate one thing, like the functioning of a dialog or something. Step through the code in your head and see if you can guess what will happen when a certain (or any!) event occurs (and don't limit what could happen to just what you want to look at. check for any possible things that could occur cause things like this will help you later when you're writing code and trying to make sure you've covered all the bases!). Then, run the debugger and step through it and see if you guessed properly.
Not only is it important to know what is happening, but it's perhaps even more important to know what is NOT happening. Think about it...
Also, before you run to find help when something doesn't work or you can't figure something out, try to fix it yourself. There are answers out there for just about everything, and with a little reasoning and/or resourcefullness on your part, you can find them. If you wanted to know how to get a listing of all the files in a given folder, perhaps check the Inside Macintosh books to see if there might be a Toolbox call that can do this. Perhaps check the info-mac /dev/src/ directory to see if there is some sample code you can look at. Check Apple's developer ftp/www site for help, information, or source code. Or, just try to reason things out. Maybe there isn't any code, but there was this one toolbox routine that gave me this part, and maybe from that i could loop it to get the names.....or whatever. Try to figure it out on your own. It might take longer, it might be a lot more frustrating, but y'know what? You're gonna learn a lot more doing it the hard way than you will taking the easy way.
Reread! You might have read something today and not understood it. Or, you read something and did understand it. Well, late on, reread it whether you understood it your not. Why? Well obviously if you didn't understand it, maybe you will now. Or if you did understand it, maybe you misunderstood originally? maybe you thought you understood it? maybe now you might know more and understand it better? Rereading anything and everything (code, books, technical documentation, etc) you can.
Don't be hard on yourself. It will take time, it will take patience. Not everyone knows it all. Don't be embarrassed to ask questions. The only dumb question is the one never asked. But of course, before you ask your question, see if the answer already exists for it (like checking the CSMP FAQ, ftp sites, web pages, etc).
And just immerse yourself in programming and learning about it. It's a lot of fun and one of the most rewarding things I've so far experienced in my life (I think marriage and having kids will probably be the other 2 most rewarding things in my life....call me a geek if you want to) :-)
Well, as you can tell, I'm not one easy to shut-up. But there are loads of things that you can read and should check out. Lemme give you a list of some things here. And don't forget something: if you have access to any on-line resources, use them. I have only ever used the Internet, so I can't speak about things like AOL and Compuserve, but I'm sure they have some good resources that are worthy of your investigation.
But if you can get on the Internet, you'll find a ton of stuff. Do check the "HAS URLs" document for some starting URLs.
Here's some other things:
Books: anything with Scott Knaster's name on it, anything with Dave Mark's name on it, and then, any other books you can find that address Macintosh programming. Try to get recent ones; there are a lot of Mac programming books out there, and some just are old (and the techniques and/or code might not work anymore (at least not without some updating) or might be doing things in a "no-longer-kosher-Macintosh-way") or fall flat. Knaster's and Mark's books are some of the best, and I highly recommend anything they've written and/or done. Oh, don't forget the "Inside Macintosh" series; these books are the definative reference books that all Macintosh programmers must have.
Periodicals: MacTech is a magazine dedicated to Macintosh programming. Very helpful, and addresses many issues that Mac developers will want to be aware of. Plus, Apple's "develop" magazine is great too (it comes from the source!). You can also find "develop" in DocViewer format on Apple's ftp site. It's a great thing if you have Internet access, a lot of hard drive space, and are short on cash. Plus, there are seperate files: one will have the full magazine, and another will be just the source code from that issue.
Code: if you have access to the Internet, check out the info-mac archive ftp sites in /info-mac/dev and /info-mac/dev/src for a lot of good code. Again, a lot of what's there is old, but it's still very useful. Plus, learning how to make old code work in a new environment is always good practice and learning. Of course, Apple's DTS archives is a wonderful place to find stuff. One big thing I'd recommend is anything written by Mark Pilgrim. He's written a lot of things and always releases the source code for them. His source code would be another good thing to check out - I learned a lot by checking out his MSG Shell. Additionally, any code that you can find for things that you use can be very helpful (you know how it works, now see how it's done!). I did this for my preferences; I use NewsWatcher to read USENET news, John Norstad releases the NewsWatcher source to the net, I wanted to impliment preferences that had the same concept as NW had, got the NW source, and off I went. Other authors that have released their source code to the net are: Norstad's Disinfectant (minus the anti-virus code, of course), I think Qualcomm's Eudora code is out there, a lot of Peter Lewis's (read: GOD :-) ) code is also available but it's all in Pascal so you'll have to translate (and if you don't know who Peter Lewis is and/or don't know what he's done for the Macintosh, I highly suggest you find out quick!). Also, Tom Bender wrote Tex-Edit+ (a groovy text editor). You can get Tex-Edit+ free off info-mac (i think in /text or /app), and then for a measly $5 shareware fee, Tom can send you his source code for Tex-Edit+. I've done this, and in future releases of HAS, I will be implimenting more things using Tom's code as a basis. Again, Tom's code is in Pascal, but the translation isn't that hard to do.
Other Shells: There have been other application shells/frameworks written. They're all good at what they do. The unfortunate thing with many of these shells is that they're "out of date" (no Copland support, no PowerMac support, still do things in a System 6/kludgy System 7 way, and/or whatever). Nevertheless, I recommend getting them and looking them over. With a little work, you can still use much of this stuff, and there's a lot of great stuff in them. I'll just list the shells that I've seen/worked with and you should be able to find them on info-mac, umich and/or apple's ftp sites: Chassis 6.0, WinterShell 1.0d2, TransSkel (original is done in Pascal, but there are C ports), AppsToGo (Apple's own framework), MacStarter (haven't used it much, but it's out there). And I'm sure there are more shells out there, just get around and find them! (incidentally, there are also Extension (INIT) shells, Control Panel (CDEV) shells, and various C++ shells like Sprocket, PowerPlant, and THINK Class Library. When/if you move to C++ (and you should consider it after you master C and basic Macintosh programming) you should check out things like PowerPlant).
Forums: again, if you have Internet access, read the various newsgroups dedicated to Mac programming: comp.sys.mac.programmer.* (where * is codewarrior, misc, help, info). You'll find many knowledgeable people that read these groups and can help with just about anything and everything. Plus, find the csmp FAQ's since they answer many of the common questions.
Misc: try to find a Macintosh Users Group in your area. There are bound to be programmers there you could talk to. Also, again if you have Internet access, get on the World Wide Web. There are lots of resources and things on there. Like I said at the beginning of this section, I have a list of many URL's at the end of this document.
And of course, just scour the net. You will find lots of great stuff (like you can find all the volumes of Inside Macintosh in both DocViewer and Acrobat pdf on Apple's ftp sites. That'll save you some money).